package com.moons.idevices.utils;

import com.moons.idevices.IPrinter;
import com.moons.idevices.model.Appointment;
import com.moons.idevices.model.Visitor;
import com.moons.idevices.printers.PrinterManager;

/**
 * 打印工具类
 */
public class PrinterUtils {


    /**
     * 打印二维码
     *
     * @param qrText
     * @param iPrinter
     */
    public static void printQRCode(String qrText, IPrinter iPrinter) {

        PrinterManager.getInstance().getPrinter().printQRCode(qrText, iPrinter);

    }


    /**
     * 打印文字
     *
     * @param text
     * @param iPrinter
     */
    public static void printerText(String text, IPrinter iPrinter) {

        PrinterManager.getInstance().getPrinter().printText(text, iPrinter);
    }


    /**
     * 打印机状态查询
     *
     * @return
     */
    public static boolean isPrintFunctional() {

        return PrinterManager.getInstance().getPrinter().isPrintFunctional();

    }


    /**
     * 打印预约信息
     *
     * @param appointment
     * @param isCut       是否打印完切纸
     */
    public static void printAppointment(Appointment appointment, boolean isCut) {

        PrinterManager.getInstance().getPrinter().printAppointment(appointment, isCut);


    }

    /**
     * 打印访客信息
     *
     * @param visitor
     * @param isCut   打印完是否切纸
     */
    public static void printVisitor(Visitor visitor, boolean isCut) {

        PrinterManager.getInstance().getPrinter().printVisitor(visitor, isCut);

    }


    /**
     * 同时打印预约信息和访客信息
     *
     * @param visitor
     * @param appointment
     */
    public static void printAppointmentAndVisitor(Visitor visitor, Appointment appointment) {

        printVisitor(visitor, false);
        printAppointment(appointment, true);

    }


}
